{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <select name="export">
                                <option value="">是否导出报表</option>
                                <option value="1" {if !empty(input('get.export')) &&
                                    input('get.export')== 1}selected{/if}>否</option>
                                <option value="2" {if !empty(input('get.export')) &&
                                    input('get.export')== 2}selected{/if}>是</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="status">
                                <option value="">交易状态</option>
                                <option value="1" {if !empty(input('get.status')) &&
                                    input('get.status')==1}selected{/if}>待审核</option>
                                <option value="2" {if !empty(input('get.status')) &&
                                    input('get.status')==2}selected{/if}>待自动转币</option>
                                <option value="3" {if !empty(input('get.status')) &&
                                    input('get.status')==3}selected{/if}>通过</option>
                                <option value="4" {if !empty(input('get.status')) &&
                                    input('get.status')==4}selected{/if}>驳回</option>
                                <option value="5" {if !empty(input('get.status')) &&
                                    input('get.status')==5}selected{/if}>自动转币失败</option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="coin">
                                <option value="">提现币种</option>
                                {if !empty($coin)}
                                {foreach $coin as $k => $v}
                                <option value="{$k}" {if !empty(input('get.coin')) &&
                                    input('get.coin')==$k}selected{/if}>{$v}</option>
                                {/foreach}
                                {/if}
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="mobile" placeholder="用户手机号|ID" value="{:input('get.mobile')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="address" placeholder="提币地址" value="{:input('get.address')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    共有数据：<strong id="count">{$list->total()}</strong> 条&nbsp;
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form" lay-size="sm">
                        <thead>
                            <tr>
                                <th width="50">ID</th>
                                <th width="100">用户信息</th>
                                <th width="50">币种类型</th>
                                <th width="50">提币数量(含手续费)</th>
                                <th width="50">手续费</th>
                                <th width="50">应该转币</th>
                                <th width="150">提币地址</th>
                                <th width="50">提币状态</th>
                                <th width="50">提币hash</th>
                                <th width="100">提币时间</th>
                                <th width="200">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>{$v.id|default='0'}</td>
                                <td>用户ID：{$v.user_id|default="0"}<br />用户手机：{$v.mobile|default=''}</td>
                                <td>{$v.cointext|default=''}</td>
                                <td>{$v.coinnum|default='0'}</td>
                                <td>{$v.handfee|default='0'}</td>
                                <td>{$v.coinnum - $v.handfee}</td>
                                <td>{$v.address|default=''}</td>
                                <td>{if $v.status == 1}
                                    <button type="button" class="layui-btn layui-btn-primary">待审核</button>
                                    {elseif $v.status == 2}
                                    <button type="button" class="layui-btn layui-btn-warm">待自动转币</button>
                                    {elseif $v.status == 3}
                                    <button type="button" class="layui-btn layui-btn-normal">成功</button>
                                    {elseif $v.status == 4}
                                    <button type="button" class="layui-btn layui-btn-danger">驳回</button>
                                    {elseif $v.status == 5}
                                    <button type="button" class="layui-btn layui-btn-disabled">自动转币失败</button>
                                    {else}
                                    {/if}
                                </td>
                                <td>{if !empty($v.hash)}<a type="button" class="layui-btn layui-btn-normal" target="_blank" href="https://cn.etherscan.com/tx/{$v.hash|default=''}" />点击查询hash</a>{/if}
                                </td>
                                <td>{$v.created|default=''}</td>
                                <td>
                                    {if $v.status == 1}
                                    <button onclick="orderstr('确定驳回订单吗?','/order/withdrawstr','{$v.id}',4)"
                                        type="button" class="layui-btn layui-btn-danger">驳回</button>
                                    <button
                                        onclick="orderstr('确定自动转币吗?请确保平台提币账户币种足够！','/order/withdrawstr','{$v.id}',2)"
                                        type="button" class="layui-btn layui-btn-warm">平台自动转</button>
                                    <button onclick="orderstr('确定通过并进行手动转吗?','/order/withdrawstr','{$v.id}',3)"
                                        type="button" class="layui-btn layui-btn-normal">线下手动转币</button>
                                    {elseif $v.status == 5 || $v.status == 2}
                                    <button
                                        onclick="orderstr('确定驳回订单吗,如果是自动转币请确认是否已自动转币?','/order/withdrawstr','{$v.id}',4)"
                                        type="button" class="layui-btn layui-btn-danger">驳回</button>
                                    <button
                                        onclick="orderstr('确定通过手动转吗，如果是自动转币失败请先确认是否已自动转币?','/order/withdrawstr','{$v.id}',3)"
                                        type="button" class="layui-btn layui-btn-normal">线下手动转币</button>
                                    {/if}
                                </td>

                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['upload', 'form'], function () {
        var $ = layui.jquery
            , upload = layui.upload
            , form = layui.form;
        //图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: 'users_top'
            , accept: 'file'
            , exts: 'xls|csv'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.status > 0) {
                    return layer.msg(res.msg);
                }
                //上传成功
                return layer.msg(res.msg);
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    });
    function showimg(imgs) {
        console.log(imgs);
        layer.open({
            type: 1,
            title: false,
            shadeClose: true,
            skin: 'layui-layer-nobg', //没有背景色
            content: "<img src='" + imgs + "' style='width:100%;height: 100%;'>"
        });
    }
    function orderstr(title, url, id, type) {
        layer.confirm(title, { title: '请谨慎操作' }, function (index) {
            $.post(url, { id: id, type: type }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                        location.reload();
                        layer.close(index);
                    });
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
    function usermoney(url, id) {
        layer.open({
            type: 2,
            area: ['80%', '80%'],
            content: url + '?mobile=' + id,
        });
    }
</script>
{include file="public/footer"}